<?php
namespace Rainrock\Framework\kernel\base;


/**
*	浏览器信息
*/
final class Web{
	
	public static function getAgent()
	{
		return Rock::arrvalue($_SERVER, 'HTTP_USER_AGENT');
	}
	
	/**
	*	是否手机端
	*/
	public static function isMobile()
	{
		$web = strtolower(self::getAgent());
		if(Rock::contain($web, 'mobile') || Rock::contain($web, 'android') || Rock::contain($web, 'iphone'))return true;
		return false;
	}
	
	/**
	*	浏览器类型
	*/
	public static function getType()
	{
		$llqarr = array("MSIE", "Safari", "Chrome", "iPhone", "Android", "Edge", "QQBrowser", "MicroMessenger","wxwork");
		$web 	= strtolower(self::getAgent());
		$llqobj = array('MicroMessenger'=>'wxbro');
		$strv	= 'unkown';
		foreach($llqarr as $val)if(Rock::contain($web, strtolower($val)))$strv = $val;
		if(isset($llqobj[$strv]))$strv = $llqobj[$strv];
		return $strv;
	}
	
	/**
	*	是否微信打开
	*/
	public static function isWeixin()
	{
		$web 	= strtolower(self::getAgent());
		return Rock::contain($web, 'micromessenger');
	}
	
	/**
	*	获取app类型
	*/
	public static function appType()
	{
		$web = self::getAgent();
		if(Rock::contain($web,'ROCKDRIVEAPP')){
			if(Rock::contain($web,'ANDROID'))return 'android';
			if(Rock::contain($web,'iPhone'))return 'ios';
		}else{
			return '';
		}
	}
	
	
	/**
	*	获取客户端IP
	*/
	public static function getIp()
	{
		return Request::getIp();
	}
}